home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / asmbler.arc / BLANK2.ASM < prev    next >
Assembly Source File  |  1988-11-19  |  5KB  |  113 lines

  1.     title    SCRNSAVE
  2. COMMENT \
  3. Resident program to  blank the  screen after  5 minutes  of no  keyboard
  4. activity.  Reconstructed from a hex dump of the .COM file given by
  5.  
  6. Christopher Wiley, in PC World Magazine, April 1984, pp. 236-237
  7.  
  8. [26-Mar-84]     Nelson H.F. Beebe, University of Utah
  9. \
  10.         assume  cs:SCRNSAVE, ds:SCRNSAVE, es:SCRNSAVE, ss:SCRNSAVE
  11.  
  12. SCRNSAVE segment para public 'code'
  13.         org     100h                    ; this will be a .COM file
  14.  
  15. TRUE    equ     1
  16. FALSE   equ     0
  17. MAXTICKS equ    500                     ; why this number for 5 minutes????
  18. USER_INT equ    60h                     ; 60..67 available, original
  19.                                         ; code used IBM reserved value
  20.                                         ; 50h
  21. START:
  22.         jmp     init                    ;jump around resident code to
  23.                                         ;transient code
  24.  
  25. kbd_active db   ?
  26. scr_blanked db   ?
  27.  
  28. KBD_HANDLER:                            ; here on keyboard interrupt
  29.         mov     kbd_active,TRUE         ; show keyboard in use
  30.         int     USER_INT                ; user interrupt code
  31.         iret                            ; return to interrupt raiser
  32.  
  33. ticks   dw      ?                       ; clock tick counter
  34. current_page db ?                       ; current active page (overlayed
  35.                                         ; ticks+1 in original version)
  36.  
  37. TIMER_HANDLER:                          ; here on timer interrupt
  38.         pushf                           ; save flags
  39.         push    ax                      ; save ax
  40.         cmp     kbd_active,TRUE         ; keyboard in use?
  41.         jne     L1                      ; no
  42.         mov     kbd_active,FALSE        ; yes, mark it inactive,
  43.         call    RESTORE_SCREEN          ; restore the screen
  44.         mov     ticks,0000              ; and clear clock tick counter
  45.  
  46. L1:
  47.         cmp     scr_blanked,TRUE        ; screen blanked already?
  48.         je      L3                      ; yes
  49.         inc     ticks                   ; no, increment timer counter
  50.         cmp     ticks,MAXTICKS          ; timer limit reached?
  51.         jne     L3                      ; not yet
  52.         call    BLANK_SCREEN            ; yes, turn off screen to save phosphor
  53.  
  54. L3:
  55.         pop     ax                      ; restore ax
  56.         popf                            ; and flags
  57.         iret                            ; and return to interrupt raiser
  58.  
  59. BLANK_SCREEN:                           ; here to blank the screen
  60.         push    ax                      ; save ax
  61.         mov     scr_blanked,TRUE        ; mark screen blanked
  62.         mov     ah,$VIDEO_SETPAGE
  63.         mov     al,07                   ; set to page 7 (normally unused)
  64.         int     $VIDEO
  65.         mov     ticks,0000              ; clear clock count
  66.         pop     ax                      ; restore ax
  67.         ret                             ; and return to caller
  68.  
  69. RESTORE_SCREEN:                         ; here to restore the blanked screen
  70.         push    ax                      ; save ax
  71.         cmp     scr_blanked,TRUE        ; already blanked?
  72.         je      L4                      ; yes
  73.         mov     ah,$VIDEO_GETVIDEOSTATE ; no, find current display page
  74.         int     $VIDEO
  75.         mov     current_page,bh         ; and save it
  76.  
  77. L4:
  78.         mov     scr_blanked,FALSE       ; show screen in use
  79.         mov     ah,$VIDEO_SETPAGE       ; and restore the display page
  80.         mov     al,current_page
  81.         int     $VIDEO
  82.         pop     ax                      ; restore ax
  83.         ret                             ; and return to caller
  84.  
  85. INIT:                                   ; here when SCRNSAVE invoked
  86.         mov     ax,0f000h               ; BIOS segment
  87.         mov     ds,ax
  88.  
  89. ; !!!BAD CODE PRACTICE - ABSOLUTE BIOS ADDRESS!!!!
  90.         mov     dx,0e987h               ; address of interrupt handler in ds:dx
  91.                                         ; this is BIOS KB_INT routine
  92.  
  93.         mov     ah,$DOS_SETINT
  94.         mov     al,USER_INT             ; interrupt type
  95.         int     $DOS                    ; restore original BIOS KB_INT handler
  96.  
  97.         mov     ax,cs
  98.         mov     ds,ax                   ; ds == cs
  99.         mov     dx,TIMER_HANDLER        ; address of interrupt handler in ds:dx
  100.         mov     ah,$DOS_SETINT          ; supply our own handler
  101.         mov     al,1ch                  ; interrupt type (timer tick, Tech
  102.         int     $DOS                    ; Ref p. 2-4)
  103.  
  104.         mov     dx,KBD_HANDLER          ; address of interrupt handler in ds:dx
  105.         mov     ah,$DOS_SETINT
  106.         mov     al,09h                  ; interrupt type (keyboard interrupt)
  107.         int     $DOS                    ; supply our own handler
  108.         mov     dx,INIT                 ; last address + 1
  109.         int     27h                     ; terminate but stay resident
  110.  
  111. SCRNSAVE ends
  112.         end     SCRNSAVE
  113.